# Maintainer: Morten Linderud <foxboron@archlinux.org>
# Contributor: Chad Kunde <Kunde21@gmail.com>

pkgname=gopls
pkgver=0.14.1
pkgrel=1
pkgdesc='Language server for Go programming language'
arch=('loong64' 'x86_64' 'aarch64' 'armv7h' 'armv7l')
url='https://github.com/golang/tools/tree/master/gopls'
license=('BSD')
depends=('go')
makedepends=('git')
options=('!lto')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/golang/tools/archive/gopls/v${pkgver}.tar.gz")
sha256sums=('33f886f65268c6b1e3e3a0177681c2aeaeba3993b2a0829d18efb49869c1ca0e')

build() {
  cd "tools-${pkgname}-v${pkgver}/${pkgname}"

  # set Go flags
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export GOPATH="${srcdir}"

  go build -v \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-compressdwarf=false \
    -linkmode external \
    -extldflags ${LDFLAGS}" \
    -o "${pkgname}"
}

package() {
  cd "tools-${pkgname}-v${pkgver}"
  install -Dm755 "${pkgname}/${pkgname}" -t "${pkgdir}"/usr/bin/
  install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}

# vim: ts=2 sw=2 et:
